let TemplateList = async (ctx, next) => {
  let res = await ctx.db.querys(`select * from templates`);
  ctx.body = { code: 1, msg: '', data: [...res] }
}




// 学生列表模糊搜索
let searchTemplateList = async (ctx, next) => {
  const { title, type } = ctx.request.body;
  let templateData = await ctx.db.querys(`select * from templates`);
  if (!templateData.length) {
    return ctx.body = { code: 0, msg: '暂无数据', data: [] }
  }
  if (title !== '') {
    templateData = templateData.filter(item => item.title.indexOf(title) !== -1)
  }
  if (type !== 'all') {
    templateData = templateData.filter(item => item.type === type)
  }

  ctx.body = { code: 1, msg: '数据请求成功', data: templateData }
}

export default {
  TemplateList, searchTemplateList
}